def hanoi(a, b, c, n):
    global sum
    if n == 1:
        sum += 1
        if sum == m:
            print(f"#{n}: {a} -> {c}")
    else:
        hanoi(a, c, b, n-1)
        sum += 1
        if sum == m:
            print(f"#{n}: {a} -> {c}")
        hanoi(b, a, c, n-1)

n, m = map(int, input().split())
sum = 0
hanoi('A', 'B', 'C', n)
print(sum)